//
//  HashrateVC.m
//  WalletAPP
//
//  Created by 罗弟祥 on 2019/10/4.
//  Copyright © 2019 罗弟祥. All rights reserved.
//

#import "HashrateVC.h"
#import "ChatValueView.h"
#import "LHYChartView.h"
#import "NaviView.h"
@interface HashrateVC ()
@property (weak, nonatomic) IBOutlet UIView *bottomView1;
@property (weak, nonatomic) IBOutlet UIProgressView *progressView;



@property (weak, nonatomic) IBOutlet UIView *bottomView2;




@property (weak, nonatomic) IBOutlet UIView *bottomView3;

@property (nonatomic, retain) NaviView *naviView;

@property (nonatomic, retain) ChatValueView *chatView;


@end
// 屏幕高度与宽度
#define screenW  [UIScreen mainScreen].bounds.size.width
#define screenH  [UIScreen mainScreen].bounds.size.height

@implementation HashrateVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    
    for (UIImageView *imgV in self.progressView.subviews) {
        imgV.layer.cornerRadius = 5;
        imgV.clipsToBounds = true;
    }
    
    [self.view addSubview:self.naviView];
    self.naviView.frame = CGRectMake(0, 0, screenW, StatusBarHeight + NavBarHeight);
    [self.naviView setBackBlock:^{
        [self.navigationController popViewControllerAnimated:YES];
    }];
    
    self.bottomView1.layer.cornerRadius = 10;
    
    [self addFirstChartView];
}


-(void)addFirstChartView{
    LHYChartView *incomeChartLineView = [[LHYChartView alloc]initWithFrame:CGRectMake(20, 50, [UIScreen mainScreen].bounds.size.width - 40, 300)];
    //是否默认选中第一个
    incomeChartLineView.isShowFirstPaoPao = YES;
    //是否有网格
    incomeChartLineView.isGrid = YES;
    //是否可以浮动
    incomeChartLineView.isFloating = NO;
    //显示多少行
    incomeChartLineView.row = 6;
    //显示多少列
    incomeChartLineView.xRow = 6;
    //设置X轴坐标字体大小
    incomeChartLineView.x_Font = [UIFont systemFontOfSize:10];
    //设置X轴坐标字体颜色
    incomeChartLineView.x_Color = [UIColor colorWithHexString:@"#999999"];
    //设置Y轴坐标字体大小
    incomeChartLineView.y_Font = [UIFont systemFontOfSize:10];
    //设置Y轴坐标字体颜色
    incomeChartLineView.y_Color = [UIColor colorWithHexString:@"#999999"];
    //设置X轴数据间隔
    incomeChartLineView.Xmargin = 55;
    //设置背景颜色
    incomeChartLineView.backgroundColor = [UIColor whiteColor];
    //边框标线颜色
    incomeChartLineView.borderLineColor = [UIColor colorWithHexString:@"#999999"];
    //中间标线颜色
    incomeChartLineView.middleLineColor = [UIColor colorWithHexString:@"#cbcbcb" andAlpha:0.5];
    //边框三角颜色
    incomeChartLineView.borderTriangleColor = [UIColor colorWithHexString:@"#999999"];
    //设置泡泡背景颜色
    incomeChartLineView.paopaoBackGroundColor = [UIColor colorWithHexString:@"#000000" andAlpha:0.85];
    incomeChartLineView.markColor = [UIColor colorWithHexString:@"#333333"];
    //设置泡泡的标题颜色
    incomeChartLineView.paopaoTitleColor = [UIColor whiteColor];
    //设置折线样式
    incomeChartLineView.chartViewStyle = LHYChartViewMoreClickLine;
    //设置图层效果
    incomeChartLineView.chartLayerStyle = LHYChartProjection;
    //设置折现效果
    incomeChartLineView.lineLayerStyle = LHYLineLayerNone;
    incomeChartLineView.paopaoBackGroundColor = [UIColor colorWithHexString:@"#111111" andAlpha:0.8];
    //渐变效果的颜色组
    //渐变开始比例
    incomeChartLineView.proportion = 0.5;
    //折线图是否从零点开始画
    incomeChartLineView.hiddenZreo = YES;
    //设置颜色
    incomeChartLineView.leftColorStrArr = @[@"#6dd89c",@"#00a1eb",@"#bc69e0",@"#385af0"];
    //折线图数据
    incomeChartLineView.leftDataArr = @[@[@"25000",@"30907",@"32010",@"33450",@"30069",@"31574",@"30692",@"33156",@"29808",@"31846",@"29772",@"29630"],@[@"46175",@"44915",@"36228",@"50473",@"28811",@"11876",@"23213",@"26847",@"27905",@"9562",@"34263",@"25459"]];
    //底部日期
    incomeChartLineView.dataArrOfX = @[@"4月",@"5月",@"6月",@"7月",@"8月",@"9月",@"10月",@"11月",@"12月",@"1月",@"2月",@"3月"];
    //泡泡标题
    incomeChartLineView.paopaoTitleArray = @[@"2018-04",@"2018-05",@"2018-06",@"2018-07",@"2018-08",@"2018-09",@"2018-10",@"2018-11",@"2018-12",@"2019-01",@"2019-02",@"2019-03"];
    //泡泡数据
    incomeChartLineView.paopaoDataArray = @[@[@"25,000元m²",@"30,907元m²",@"32,010元m²",@"33,450元m²",@"30,069元m²",@"31,574元m²",@"30,692元m²",@"33,156元m²",@"29,808元m²",@"31,846元m²",@"29,772元m²",@"29,630元m²"],@[@"46,175元m²",@"44,915元m²",@"36,228元m²",@"50,473元m²",@"28,811元m²",@"11,876元m²",@"23,213元m²",@"26,847元m²",@"27,905元m²",@"9,562元m²",@"34,263元m²",@"25,459元m²"]];
    //开始画图
    [incomeChartLineView show];
    [self.bottomView2 addSubview:incomeChartLineView];
}
- (IBAction)detailBtnClick:(UIButton *)sender {
    [self setChatViewBlock];
    
}

-(void)setChatViewBlock{
    
    [self.view addSubview:self.chatView];
    [self.chatView setCellBlock:^{
        
        [UIView animateWithDuration:0.3 animations:^{
            self.chatView.frame = CGRectMake(0, screenH, screenW, 400);
            [self.view setNeedsLayout];
        }];
        
        
    }];
    self.chatView.frame = CGRectMake(0, screenH, screenW, 500);
    
    [UIView animateWithDuration:0.6 animations:^{
        self.chatView.frame = CGRectMake(0, screenH - 515, screenW, 500);
        [self.view layoutIfNeeded];
        [self.view setNeedsLayout];
    } completion:^(BOOL finished) {
        //        [self shakeAnimationForView:self.hView];
        self.chatView.frame = CGRectMake(0, screenH - 500, screenW, 500);
        [UIView animateWithDuration:0.3 animations:^{
            [self.view layoutIfNeeded];
            [self.view setNeedsLayout];
        }];
    }];
    
    
}

-(ChatValueView *)chatView{
    if (!_chatView) {
        _chatView = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([ChatValueView class]) owner:self options:nil].firstObject;
        
    }
    return _chatView;
}


-(NaviView *)naviView{
    if (!_naviView) {
        _naviView = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([NaviView class]) owner:self options:nil].firstObject;
    }
    return _naviView;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
